const app = getApp();
Page({
  data: {
    result: {},
    tenancyName: app.globalData.tenancyName,
    url:''
  },
  scanLogin: function () {
    let _this = this;
    wx.scanCode({
      onlyFromCamera: true,
      success: (res) => {
        console.log(res)
        let obj = JSON.parse(res.result);
        if (obj.connectionid && obj.uuid) {
          //如果有这两个值则证明扫码成功 出现确认登录弹层
          _this.setData({
            result: JSON.parse(res.result),
          });
          wx.navigateTo({
            url: '/pages/scan/scan?result=' + res.result,
          })
        } else {
          wx.showToast({
            title: '二维码不正确，请重新扫码',
            icon: 'none',
            duration: 2000
          })
        }
        console.log("这里是二维码")
      }
    })
  },
  copyurl:function(){
    let _this = this;
    this.setData({
      url: 'http://yjff.zhibaoke.com/#/login?tenancyName=' + app.globalData.tenancyName
    })
    wx.setClipboardData({
      data: this.data.url,
      success: function (res) {
        console.log(_this.data.url);
        wx.showToast({
          title: '复制成功',
          icon: 'none',
          duration: 2000
        })
        // wx.getClipboardData({
        //   success: function (res) {
        //     console.log(res.data) // data
        //   }
        // })
      }
    })
  }
})